package com.ruoyi.util.concretecheck;

/**
 * @author 62418
 * @since 2020/8/20 8:00
 */

import com.ruoyi.domain.jpjs.common.brickcheck.BrickCheck;
import com.ruoyi.domain.jpjs.common.concretecheck.ConcreteCheck;
import com.ruoyi.domain.jpjs.common.plastercheck.PlasterCheck;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;

import java.io.FileOutputStream;
import java.util.List;

public class ExportAllExcel {
    public void getValue(List<ConcreteCheck> concreteList, List<BrickCheck> brickcheckList, List<PlasterCheck> plastercheckList, FileOutputStream fout){
        try{

            //1.创建工作簿
            HSSFWorkbook workbook = new HSSFWorkbook();

            //1.1创建合并单元格对象
            CellRangeAddress callRangeAddress = new CellRangeAddress(0,0,0,32);//起始行,结束行,起始列,结束列

            // 标题
            CellRangeAddress callRangeAddress31 = new CellRangeAddress(1,2,0,0);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress32 = new CellRangeAddress(1,2,1,1);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress33 = new CellRangeAddress(1,2,2,2);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress34 = new CellRangeAddress(1,2,3,3);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress35 = new CellRangeAddress(1,2,4,4);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress36 = new CellRangeAddress(1,2,5,5);//起始行,结束行,起始列,结束列

            CellRangeAddress callRangeAddress37 = new CellRangeAddress(1,1,6,8);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress371 = new CellRangeAddress(1,1,9,11);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress372 = new CellRangeAddress(1,1,12,14);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress373 = new CellRangeAddress(1,1,15,17);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress374 = new CellRangeAddress(1,1,18,20);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress375 = new CellRangeAddress(1,1,21,23);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress376 = new CellRangeAddress(1,1,24,26);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress377 = new CellRangeAddress(1,1,27,29);//起始行,结束行,起始列,结束列

            CellRangeAddress callRangeAddress40 = new CellRangeAddress(1,2,30,30);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress41 = new CellRangeAddress(1,2,31,31);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress42 = new CellRangeAddress(1,2,32,32);//起始行,结束行,起始列,结束列


            // 项目混凝土强度试验检测统计表
            HSSFCellStyle headStyle = createCellStyle(workbook,(short)16,true,true);
            // 工程公司
            HSSFCellStyle erStyle = createCellStyle(workbook,(short)13,true,true);
            // 标题样式
            HSSFCellStyle colStyle = createCellStyle(workbook,(short)10,true,true);
            //内容样式
            HSSFCellStyle cellStyle = createCellStyle(workbook,(short)10,false,true);

            //2.创建工作表
            HSSFSheet sheet = workbook.createSheet("混凝土实测统计表");
            HSSFSheet sheetbrick = workbook.createSheet("砌体实测统计表");
            HSSFSheet sheetplaster = workbook.createSheet("抹灰实测统计表");

            //2.1加载合并单元格对象
            sheet.addMergedRegion(callRangeAddress);
            sheet.addMergedRegion(callRangeAddress31);
            sheet.addMergedRegion(callRangeAddress32);
            sheet.addMergedRegion(callRangeAddress33);
            sheet.addMergedRegion(callRangeAddress34);
            sheet.addMergedRegion(callRangeAddress35);
            sheet.addMergedRegion(callRangeAddress36);

            sheet.addMergedRegion(callRangeAddress37);
            sheet.addMergedRegion(callRangeAddress371);
            sheet.addMergedRegion(callRangeAddress372);
            sheet.addMergedRegion(callRangeAddress373);
            sheet.addMergedRegion(callRangeAddress374);
            sheet.addMergedRegion(callRangeAddress375);
            sheet.addMergedRegion(callRangeAddress376);
            sheet.addMergedRegion(callRangeAddress377);

            sheet.addMergedRegion(callRangeAddress40);
            sheet.addMergedRegion(callRangeAddress41);
            sheet.addMergedRegion(callRangeAddress42);

            //设置默认列宽
            sheet.setDefaultColumnWidth(15);
            //3.创建行
            //3.1创建头标题行;并且设置头标题
            HSSFRow row = sheet.createRow(0);
            HSSFCell cell = row.createCell(0);

            //加载单元格样式
            cell.setCellStyle(headStyle);
            cell.setCellValue("混凝土实测统计表");

            //3.2创建列标题;并且设置列标题
            HSSFRow row2 = sheet.createRow(1);
            String[] titles = {"序号","工程公司","项目名称","工程部位","结构部位","浇筑日期","汇总","","", "垂直度","","","平整度","","","截面尺寸","","","阴阳角","","","开间尺寸","","","顶板水平度","","","楼板厚度","","", "备注","录入人员","检测人员"};//""为占位字符串

            for(int i=0;i<titles.length;i++)
            {
                HSSFCell cell2 = row2.createCell(i);
                //加载单元格样式
                cell2.setCellStyle(colStyle);
                cell2.setCellValue(titles[i]);
            }

            HSSFRow rowfour = sheet.createRow(2);
            String[] titlefour = {"检测点数","合格点数","合格率","检测点数","合格点数","合格率","检测点数","合格点数","合格率","检测点数","合格点数","合格率","检测点数","合格点数","合格率","检测点数","合格点数","合格率","检测点数","合格点数","合格率","检测点数","合格点数","合格率"};
            for(int i=0;i<titlefour.length;i++)
            {
                HSSFCell cell2 = rowfour.createCell(i+6);
                //加载单元格样式
                cell2.setCellStyle(colStyle);
                cell2.setCellValue(titlefour[i]);
            }

            //4.操作单元格;将用户列表写入excel
            if(concreteList != null) {
                int i = 1;
                for (int j = 0; j < concreteList.size(); j++) {
                    //创建数据行,前面有两行,头标题行和列标题行
                    HSSFRow row3 = sheet.createRow(j + 3);
                    HSSFCell cell0 = row3.createCell(0);
                    cell0.setCellStyle(cellStyle);
                    cell0.setCellValue(i++);

                    HSSFCell cell1 = row3.createCell(1);
                    cell1.setCellStyle(cellStyle);
                    cell1.setCellValue(concreteList.get(j).getCompanyName());

                    HSSFCell cell2 = row3.createCell(2);
                    cell2.setCellStyle(cellStyle);
                    cell2.setCellValue(concreteList.get(j).getProgramName());


                    HSSFCell cell3 = row3.createCell(3);
                    cell3.setCellStyle(cellStyle);
                    cell3.setCellValue(concreteList.get(j).getBuildingNumber());

                    HSSFCell cell4 = row3.createCell(4);
                    cell4.setCellStyle(cellStyle);
                    cell4.setCellValue(concreteList.get(j).getFloorNumber());

                    HSSFCell cell5 = row3.createCell(5);
                    cell5.setCellStyle(cellStyle);
                    cell5.setCellValue(concreteList.get(j).getPouringTime());

                    // 汇总
                    HSSFCell cell6 = row3.createCell(6);
                    cell6.setCellStyle(cellStyle);
                    cell6.setCellValue(concreteList.get(j).getTotalCheck());

                    HSSFCell cell7 = row3.createCell(7);
                    cell7.setCellStyle(cellStyle);
                    cell7.setCellValue(concreteList.get(j).getTotalActual());

                    HSSFCell cell8 = row3.createCell(8);
                    cell8.setCellStyle(cellStyle);
                    cell8.setCellValue(concreteList.get(j).getTotalRate());

                    // 垂直度
                    HSSFCell cell9 = row3.createCell(9);
                    cell9.setCellStyle(cellStyle);
                    cell9.setCellValue(concreteList.get(j).getVerticalityCheck());

                    HSSFCell cell10 = row3.createCell(10);
                    cell10.setCellStyle(cellStyle);
                    cell10.setCellValue(concreteList.get(j).getVerticalityActual());

                    HSSFCell cell11 = row3.createCell(11);
                    cell11.setCellStyle(cellStyle);
                    cell11.setCellValue(concreteList.get(j).getVerticalityRate());

                    // 平整度
                    HSSFCell cell12 = row3.createCell(12);
                    cell12.setCellStyle(cellStyle);
                    cell12.setCellValue(concreteList.get(j).getPlanenessCheck());

                    HSSFCell cell13 = row3.createCell(13);
                    cell13.setCellStyle(cellStyle);
                    cell13.setCellValue(concreteList.get(j).getPlanenessActual());

                    HSSFCell cell14 = row3.createCell(14);
                    cell14.setCellStyle(cellStyle);
                    cell14.setCellValue(concreteList.get(j).getPlanenessRate());

                    // 截面尺寸
                    HSSFCell cell15 = row3.createCell(15);
                    cell15.setCellStyle(cellStyle);
                    cell15.setCellValue(concreteList.get(j).getSectionCheck());

                    HSSFCell cell16 = row3.createCell(16);
                    cell16.setCellStyle(cellStyle);
                    cell16.setCellValue(concreteList.get(j).getSectionActual());

                    HSSFCell cell17 = row3.createCell(17);
                    cell17.setCellStyle(cellStyle);
                    cell17.setCellValue(concreteList.get(j).getSectionRate());

                    // 阴阳角
                    HSSFCell cell18 = row3.createCell(18);
                    cell18.setCellStyle(cellStyle);
                    cell18.setCellValue(concreteList.get(j).getAngleCheck());

                    HSSFCell cell19 = row3.createCell(19);
                    cell19.setCellStyle(cellStyle);
                    cell19.setCellValue(concreteList.get(j).getAngleActual());

                    HSSFCell cell20 = row3.createCell(20);
                    cell20.setCellStyle(cellStyle);
                    cell20.setCellValue(concreteList.get(j).getAngleRate());


                    // 开间尺寸
                    HSSFCell cell21 = row3.createCell(21);
                    cell21.setCellStyle(cellStyle);
                    cell21.setCellValue(concreteList.get(j).getBayCheck());

                    HSSFCell cell22 = row3.createCell(22);
                    cell22.setCellStyle(cellStyle);
                    cell22.setCellValue(concreteList.get(j).getBayActual());

                    HSSFCell cell23 = row3.createCell(23);
                    cell23.setCellStyle(cellStyle);
                    cell23.setCellValue(concreteList.get(j).getBayRate());

                    // 顶板水平度
                    HSSFCell cell24 = row3.createCell(24);
                    cell24.setCellStyle(cellStyle);
                    cell24.setCellValue(concreteList.get(j).getRoofCheck());

                    HSSFCell cell25 = row3.createCell(25);
                    cell25.setCellStyle(cellStyle);
                    cell25.setCellValue(concreteList.get(j).getRoofActual());

                    HSSFCell cell26 = row3.createCell(26);
                    cell26.setCellStyle(cellStyle);
                    cell26.setCellValue(concreteList.get(j).getRoofRate());

                    // 楼板厚度
                    HSSFCell cell27 = row3.createCell(27);
                    cell27.setCellStyle(cellStyle);
                    cell27.setCellValue(concreteList.get(j).getFloorslabCheck());

                    HSSFCell cell28 = row3.createCell(28);
                    cell28.setCellStyle(cellStyle);
                    cell28.setCellValue(concreteList.get(j).getFloorslabActual());

                    HSSFCell cell29 = row3.createCell(29);
                    cell29.setCellStyle(cellStyle);
                    cell29.setCellValue(concreteList.get(j).getFloorslabRate());


                    HSSFCell cell30 = row3.createCell(30);
                    cell30.setCellStyle(cellStyle);
                    cell30.setCellValue(concreteList.get(j).getNote());

                    HSSFCell cell31 = row3.createCell(31);
                    cell31.setCellStyle(cellStyle);
                    cell31.setCellValue(concreteList.get(j).getCheckPerson());

                    HSSFCell cell32 = row3.createCell(32);
                    cell32.setCellStyle(cellStyle);
                    cell32.setCellValue(concreteList.get(j).getTestPerson());
                }
            }
            // 砌体
            //1.1创建合并单元格对象
            CellRangeAddress callRangeAddressbrick = new CellRangeAddress(0, 0, 0, 23);//起始行,结束行,起始列,结束列

            // 标题
            CellRangeAddress callRangeAddress31brick = new CellRangeAddress(1, 2, 0, 0);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress32brick = new CellRangeAddress(1, 2, 1, 1);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress33brick = new CellRangeAddress(1, 2, 2, 2);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress34brick = new CellRangeAddress(1, 2, 3, 3);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress35brick = new CellRangeAddress(1, 2, 4, 4);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress36brick = new CellRangeAddress(1, 2, 5, 5);//起始行,结束行,起始列,结束列

            CellRangeAddress callRangeAddress37brick = new CellRangeAddress(1, 1, 6, 8);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress371brick = new CellRangeAddress(1, 1, 9, 11);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress372brick = new CellRangeAddress(1, 1, 12, 14);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress373brick = new CellRangeAddress(1, 1, 15, 17);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress374brick = new CellRangeAddress(1, 1, 18, 20);//起始行,结束行,起始列,结束列

            CellRangeAddress callRangeAddress40brick = new CellRangeAddress(1, 2, 21, 21);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress41brick = new CellRangeAddress(1, 2, 22, 22);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress42brick = new CellRangeAddress(1, 2, 23, 23);//起始行,结束行,起始列,结束列

            //2.1加载合并单元格对象
            sheetbrick.addMergedRegion(callRangeAddressbrick);
            sheetbrick.addMergedRegion(callRangeAddress31brick);
            sheetbrick.addMergedRegion(callRangeAddress32brick);
            sheetbrick.addMergedRegion(callRangeAddress33brick);
            sheetbrick.addMergedRegion(callRangeAddress34brick);
            sheetbrick.addMergedRegion(callRangeAddress35brick);
            sheetbrick.addMergedRegion(callRangeAddress36brick);

            sheetbrick.addMergedRegion(callRangeAddress37brick);
            sheetbrick.addMergedRegion(callRangeAddress371brick);
            sheetbrick.addMergedRegion(callRangeAddress372brick);
            sheetbrick.addMergedRegion(callRangeAddress373brick);
            sheetbrick.addMergedRegion(callRangeAddress374brick);

            sheetbrick.addMergedRegion(callRangeAddress40brick);
            sheetbrick.addMergedRegion(callRangeAddress41brick);
            sheetbrick.addMergedRegion(callRangeAddress42brick);

            //设置默认列宽
            sheetbrick.setDefaultColumnWidth(15);
            //3.创建行
            //3.1创建头标题行;并且设置头标题
            HSSFRow rowbrick = sheetbrick.createRow(0);
            HSSFCell cellbrick = rowbrick.createCell(0);

            //加载单元格样式
            cellbrick.setCellStyle(headStyle);
            cellbrick.setCellValue("砌体实测统计表");

            //3.2创建列标题;并且设置列标题
            HSSFRow row2brick = sheetbrick.createRow(1);
            String[] titlesbrick = {"序号", "工程公司", "项目名称", "工程部位", "结构部位", "施工完成时间", "汇总", "", "","垂直度", "", "", "平整度", "", "", "门窗洞口尺寸", "", "", "开间尺寸", "", "", "备注","录入人员","检测人员"};//""为占位字符串

            for (int ibrick = 0; ibrick < titlesbrick.length; ibrick++) {
                HSSFCell cell2brick = row2brick.createCell(ibrick);
                //加载单元格样式
                cell2brick.setCellStyle(colStyle);
                cell2brick.setCellValue(titlesbrick[ibrick]);
            }

            HSSFRow rowfourbrick = sheetbrick.createRow(2);
            String[] titlefour1 = {"检测点数", "合格点数", "合格率","检测点数", "合格点数", "合格率", "检测点数", "合格点数", "合格率", "检测点数", "合格点数", "合格率", "检测点数", "合格点数", "合格率"};
            for (int i1 = 0; i1 < titlefour1.length; i1++) {
                HSSFCell cell2brick = rowfourbrick.createCell(i1 + 6);
                //加载单元格样式
                cell2brick.setCellStyle(colStyle);
                cell2brick.setCellValue(titlefour1[i1]);
            }

            //4.操作单元格;将用户列表写入excel
            if (brickcheckList != null) {
                int ibri = 1;
                for (int jbri = 0; jbri < brickcheckList.size(); jbri++) {
                    //创建数据行,前面有两行,头标题行和列标题行
                    HSSFRow row3brick = sheetbrick.createRow(jbri + 3);
                    HSSFCell cell0brick = row3brick.createCell(0);
                    cell0brick.setCellStyle(cellStyle);
                    cell0brick.setCellValue(ibri++);

                    HSSFCell cell1brick = row3brick.createCell(1);
                    cell1brick.setCellStyle(cellStyle);
                    cell1brick.setCellValue(brickcheckList.get(jbri).getCompanyName());

                    HSSFCell cell2brick = row3brick.createCell(2);
                    cell2brick.setCellStyle(cellStyle);
                    cell2brick.setCellValue(brickcheckList.get(jbri).getProgramName());


                    HSSFCell cell3brick = row3brick.createCell(3);
                    cell3brick.setCellStyle(cellStyle);
                    cell3brick.setCellValue(brickcheckList.get(jbri).getBuildingNumber());

                    HSSFCell cell4brick = row3brick.createCell(4);
                    cell4brick.setCellStyle(cellStyle);
                    cell4brick.setCellValue(brickcheckList.get(jbri).getFloorNumber());

                    HSSFCell cell5brick = row3brick.createCell(5);
                    cell5brick.setCellStyle(cellStyle);
                    cell5brick.setCellValue(brickcheckList.get(jbri).getPouringTime());

                    // 汇总
                    HSSFCell cell6brick = row3brick.createCell(6);
                    cell6brick.setCellStyle(cellStyle);
                    cell6brick.setCellValue(brickcheckList.get(jbri).getTotalCheck());

                    HSSFCell cell7brick = row3brick.createCell(7);
                    cell7brick.setCellStyle(cellStyle);
                    cell7brick.setCellValue(brickcheckList.get(jbri).getTotalActual());

                    HSSFCell cell8brick = row3brick.createCell(8);
                    cell8brick.setCellStyle(cellStyle);
                    cell8brick.setCellValue(brickcheckList.get(jbri).getTotalRate());

                    // 垂直度
                    HSSFCell cell9brick = row3brick.createCell(9);
                    cell9brick.setCellStyle(cellStyle);
                    cell9brick.setCellValue(brickcheckList.get(jbri).getVerticalityCheck());

                    HSSFCell cell10brick = row3brick.createCell(10);
                    cell10brick.setCellStyle(cellStyle);
                    cell10brick.setCellValue(brickcheckList.get(jbri).getVerticalityActual());

                    HSSFCell cell11brick = row3brick.createCell(11);
                    cell11brick.setCellStyle(cellStyle);
                    cell11brick.setCellValue(brickcheckList.get(jbri).getVerticalityRate());

                    // 平整度
                    HSSFCell cell12brick = row3brick.createCell(12);
                    cell12brick.setCellStyle(cellStyle);
                    cell12brick.setCellValue(brickcheckList.get(jbri).getPlanenessCheck());

                    HSSFCell cell13brick = row3brick.createCell(13);
                    cell13brick.setCellStyle(cellStyle);
                    cell13brick.setCellValue(brickcheckList.get(jbri).getPlanenessActual());

                    HSSFCell cell14brick = row3brick.createCell(14);
                    cell14brick.setCellStyle(cellStyle);
                    cell14brick.setCellValue(brickcheckList.get(jbri).getPlanenessRate());

                    // 门窗洞口尺寸
                    HSSFCell cell15brick = row3brick.createCell(15);
                    cell15brick.setCellStyle(cellStyle);
                    cell15brick.setCellValue(brickcheckList.get(jbri).getDoorCheck());

                    HSSFCell cell16brick = row3brick.createCell(16);
                    cell16brick.setCellStyle(cellStyle);
                    cell16brick.setCellValue(brickcheckList.get(jbri).getDoorActual());

                    HSSFCell cell17brick = row3brick.createCell(17);
                    cell17brick.setCellStyle(cellStyle);
                    cell17brick.setCellValue(brickcheckList.get(jbri).getDoorRate());

                    // 开间尺寸
                    HSSFCell cell18brick = row3brick.createCell(18);
                    cell18brick.setCellStyle(cellStyle);
                    cell18brick.setCellValue(brickcheckList.get(jbri).getBayCheck());

                    HSSFCell cell19brick = row3brick.createCell(19);
                    cell19brick.setCellStyle(cellStyle);
                    cell19brick.setCellValue(brickcheckList.get(jbri).getBayActual());

                    HSSFCell cell20brick = row3brick.createCell(20);
                    cell20brick.setCellStyle(cellStyle);
                    cell20brick.setCellValue(brickcheckList.get(jbri).getBayRate());

                    HSSFCell cell21brick = row3brick.createCell(21);
                    cell21brick.setCellStyle(cellStyle);
                    cell21brick.setCellValue(brickcheckList.get(jbri).getNote());

                    HSSFCell cell22brick = row3brick.createCell(22);
                    cell22brick.setCellStyle(cellStyle);
                    cell22brick.setCellValue(brickcheckList.get(jbri).getNote());

                    HSSFCell cell23brick = row3brick.createCell(23);
                    cell23brick.setCellStyle(cellStyle);
                    cell23brick.setCellValue(brickcheckList.get(jbri).getTestPerson());
                }
            }

            // 抹灰
            //1.创建工作簿
            //1.1创建合并单元格对象
            CellRangeAddress callRangeAddressPla = new CellRangeAddress(0, 0, 0, 26);//起始行,结束行,起始列,结束列

            // 标题
            CellRangeAddress callRangeAddress31Pla = new CellRangeAddress(1, 2, 0, 0);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress32Pla = new CellRangeAddress(1, 2, 1, 1);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress33Pla = new CellRangeAddress(1, 2, 2, 2);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress34Pla = new CellRangeAddress(1, 2, 3, 3);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress35Pla = new CellRangeAddress(1, 2, 4, 4);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress36Pla = new CellRangeAddress(1, 2, 5, 5);//起始行,结束行,起始列,结束列

            CellRangeAddress callRangeAddress37Pla = new CellRangeAddress(1, 1, 6, 8);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress371Pla = new CellRangeAddress(1, 1, 9, 11);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress372Pla = new CellRangeAddress(1, 1, 12, 14);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress373Pla = new CellRangeAddress(1, 1, 15, 17);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress374Pla = new CellRangeAddress(1, 1, 18, 20);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress375Pla = new CellRangeAddress(1, 1, 21, 23);//起始行,结束行,起始列,结束列

            CellRangeAddress callRangeAddress40Pla = new CellRangeAddress(1, 2, 24, 24);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress41Pla = new CellRangeAddress(1, 2, 25, 25);//起始行,结束行,起始列,结束列
            CellRangeAddress callRangeAddress42Pla = new CellRangeAddress(1, 2, 26, 26);//起始行,结束行,起始列,结束列

            //2.1加载合并单元格对象
            sheetplaster.addMergedRegion(callRangeAddressPla);
            sheetplaster.addMergedRegion(callRangeAddress31Pla);
            sheetplaster.addMergedRegion(callRangeAddress32Pla);
            sheetplaster.addMergedRegion(callRangeAddress33Pla);
            sheetplaster.addMergedRegion(callRangeAddress34Pla);
            sheetplaster.addMergedRegion(callRangeAddress35Pla);
            sheetplaster.addMergedRegion(callRangeAddress36Pla);


            sheetplaster.addMergedRegion(callRangeAddress37Pla);
            sheetplaster.addMergedRegion(callRangeAddress371Pla);
            sheetplaster.addMergedRegion(callRangeAddress372Pla);
            sheetplaster.addMergedRegion(callRangeAddress373Pla);
            sheetplaster.addMergedRegion(callRangeAddress374Pla);
            sheetplaster.addMergedRegion(callRangeAddress375Pla);

            sheetplaster.addMergedRegion(callRangeAddress40Pla);
            sheetplaster.addMergedRegion(callRangeAddress41Pla);
            sheetplaster.addMergedRegion(callRangeAddress42Pla);

            //设置默认列宽
            sheetplaster.setDefaultColumnWidth(15);
            //3.创建行
            //3.1创建头标题行;并且设置头标题
            HSSFRow rowPla = sheetplaster.createRow(0);
            HSSFCell cellPla = rowPla.createCell(0);

            //加载单元格样式
            cellPla.setCellStyle(headStyle);
            cellPla.setCellValue("抹灰实测统计表");

            //3.2创建列标题;并且设置列标题
            HSSFRow row2Pla = sheetplaster.createRow(1);
            String[] titlesPla = {"序号", "工程公司", "项目名称", "工程部位", "结构部位", "施工完成时间","汇总", "", "","垂直度", "", "", "平整度", "", "", "阴阳角", "", "", "开间尺寸", "", "", "地坪平整度", "", "","备注","录入人员","检测人员"};//""为占位字符串

            for (int iPla = 0; iPla < titlesPla.length; iPla++) {
                HSSFCell cell2Pla = row2Pla.createCell(iPla);
                //加载单元格样式
                cell2Pla.setCellStyle(colStyle);
                cell2Pla.setCellValue(titlesPla[iPla]);
            }

            HSSFRow rowfourPla = sheetplaster.createRow(2);
            String[] titlefourPla = {"检测点数", "合格点数", "合格率","检测点数", "合格点数", "合格率","检测点数", "合格点数", "合格率", "检测点数", "合格点数", "合格率", "检测点数", "合格点数", "合格率", "检测点数", "合格点数", "合格率"};
            for (int iPla1 = 0; iPla1 < titlefourPla.length; iPla1++) {
                HSSFCell cell2Pla1 = rowfourPla.createCell(iPla1 + 6);
                //加载单元格样式
                cell2Pla1.setCellStyle(colStyle);
                cell2Pla1.setCellValue(titlefourPla[iPla1]);
            }

            //4.操作单元格;将用户列表写入excel
            if (plastercheckList != null) {
                int ip = 1;
                for (int jp = 0; jp < plastercheckList.size(); jp++) {
                    //创建数据行,前面有两行,头标题行和列标题行
                    HSSFRow row3Pla = sheetplaster.createRow(jp + 3);
                    HSSFCell cell0Pla = row3Pla.createCell(0);
                    cell0Pla.setCellStyle(cellStyle);
                    cell0Pla.setCellValue(ip++);

                    HSSFCell cell1Pla = row3Pla.createCell(1);
                    cell1Pla.setCellStyle(cellStyle);
                    cell1Pla.setCellValue(plastercheckList.get(jp).getCompanyName());

                    HSSFCell cell2Pla = row3Pla.createCell(2);
                    cell2Pla.setCellStyle(cellStyle);
                    cell2Pla.setCellValue(plastercheckList.get(jp).getProgramName());


                    HSSFCell cell3Pla = row3Pla.createCell(3);
                    cell3Pla.setCellStyle(cellStyle);
                    cell3Pla.setCellValue(plastercheckList.get(jp).getBuildingNumber());

                    HSSFCell cell4Pla = row3Pla.createCell(4);
                    cell4Pla.setCellStyle(cellStyle);
                    cell4Pla.setCellValue(plastercheckList.get(jp).getFloorNumber());

                    HSSFCell cell5Pla = row3Pla.createCell(5);
                    cell5Pla.setCellStyle(cellStyle);
                    cell5Pla.setCellValue(plastercheckList.get(jp).getPouringTime());

                    // 汇总
                    HSSFCell cell6Pla = row3Pla.createCell(6);
                    cell6Pla.setCellStyle(cellStyle);
                    cell6Pla.setCellValue(plastercheckList.get(jp).getTotalCheck());

                    HSSFCell cell7Pla = row3Pla.createCell(7);
                    cell7Pla.setCellStyle(cellStyle);
                    cell7Pla.setCellValue(plastercheckList.get(jp).getTotalActual());

                    HSSFCell cell8Pla = row3Pla.createCell(8);
                    cell8Pla.setCellStyle(cellStyle);
                    cell8Pla.setCellValue(plastercheckList.get(jp).getTotalRate());

                    // 垂直度
                    HSSFCell cell9Pla = row3Pla.createCell(9);
                    cell9Pla.setCellStyle(cellStyle);
                    cell9Pla.setCellValue(plastercheckList.get(jp).getVerticalityCheck());

                    HSSFCell cell10Pla = row3Pla.createCell(10);
                    cell10Pla.setCellStyle(cellStyle);
                    cell10Pla.setCellValue(plastercheckList.get(jp).getVerticalityActual());

                    HSSFCell cell11Pla = row3Pla.createCell(11);
                    cell11Pla.setCellStyle(cellStyle);
                    cell11Pla.setCellValue(plastercheckList.get(jp).getVerticalityRate());

                    // 平整度
                    HSSFCell cell12Pla = row3Pla.createCell(12);
                    cell12Pla.setCellStyle(cellStyle);
                    cell12Pla.setCellValue(plastercheckList.get(jp).getPlanenessCheck());

                    HSSFCell cell13Pla = row3Pla.createCell(13);
                    cell13Pla.setCellStyle(cellStyle);
                    cell13Pla.setCellValue(plastercheckList.get(jp).getPlanenessActual());

                    HSSFCell cell14Pla = row3Pla.createCell(14);
                    cell14Pla.setCellStyle(cellStyle);
                    cell14Pla.setCellValue(plastercheckList.get(jp).getPlanenessRate());

                    // 阴阳角
                    HSSFCell cell15Pla = row3Pla.createCell(15);
                    cell15Pla.setCellStyle(cellStyle);
                    cell15Pla.setCellValue(plastercheckList.get(jp).getAngleCheck());

                    HSSFCell cell16Pla = row3Pla.createCell(16);
                    cell16Pla.setCellStyle(cellStyle);
                    cell16Pla.setCellValue(plastercheckList.get(jp).getAngleActual());

                    HSSFCell cell17Pla = row3Pla.createCell(17);
                    cell17Pla.setCellStyle(cellStyle);
                    cell17Pla.setCellValue(plastercheckList.get(jp).getAngleRate());

                    // 开间尺寸
                    HSSFCell cell18Pla = row3Pla.createCell(18);
                    cell18Pla.setCellStyle(cellStyle);
                    cell18Pla.setCellValue(plastercheckList.get(jp).getBayCheck());

                    HSSFCell cell19Pla = row3Pla.createCell(19);
                    cell19Pla.setCellStyle(cellStyle);
                    cell19Pla.setCellValue(plastercheckList.get(jp).getBayActual());

                    HSSFCell cell20Pla = row3Pla.createCell(20);
                    cell20Pla.setCellStyle(cellStyle);
                    cell20Pla.setCellValue(plastercheckList.get(jp).getBayRate());

                    // 地坪平整度
                    HSSFCell cell21Pla = row3Pla.createCell(21);
                    cell21Pla.setCellStyle(cellStyle);
                    cell21Pla.setCellValue(plastercheckList.get(jp).getFloorCheck());

                    HSSFCell cell22Pla = row3Pla.createCell(22);
                    cell22Pla.setCellStyle(cellStyle);
                    cell22Pla.setCellValue(plastercheckList.get(jp).getFloorActual());

                    HSSFCell cell23Pla = row3Pla.createCell(23);
                    cell23Pla.setCellStyle(cellStyle);
                    cell23Pla.setCellValue(plastercheckList.get(jp).getFloorRate());

                    HSSFCell cell24Pla = row3Pla.createCell(24);
                    cell24Pla.setCellStyle(cellStyle);
                    cell24Pla.setCellValue(plastercheckList.get(jp).getNote());

                    HSSFCell cell25Pla = row3Pla.createCell(25);
                    cell25Pla.setCellStyle(cellStyle);
                    cell25Pla.setCellValue(plastercheckList.get(jp).getCheckPerson());

                    HSSFCell cell26Pla = row3Pla.createCell(26);
                    cell26Pla.setCellStyle(cellStyle);
                    cell26Pla.setCellValue(plastercheckList.get(jp).getTestPerson());
                }
            }
            //5.输出
            workbook.write(fout);
        }catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    /**
     *
     * @param workbook
     * @param fontsize
     * @return 单元格样式
     */
    private static HSSFCellStyle createCellStyle(HSSFWorkbook workbook, short fontsize,boolean flag,boolean flag1) {
        // TODO Auto-generated method stub
        HSSFCellStyle style = workbook.createCellStyle();
        //是否水平居中
        if(flag1){
            style.setAlignment(HorizontalAlignment.CENTER);//水平居中
        }

        style.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
        //创建字体
        HSSFFont font = workbook.createFont();
        //是否加粗字体
        if(flag){
            font.setBold(true);
        }
        font.setFontHeightInPoints(fontsize);
        //加载字体
        style.setFont(font);
        return style;
    }
}
